// 完成表单验证
// let form = layui.form;
// form.verify({
//   uname: [/^\S{2,10}$/, "用户名长度必须是2~10位"],
//   len: [/^\S{2,12}$/, "密码长度必须是2~12位"],
// });
// 登录功能
$(".log form").on("submit", function (e) {
  e.preventDefault();
  let data = $(this).serialize();
  console.log(data);
  $.ajax({
    type: "POST",
    url: "/api/login",
    data: data,
    success: function (res) {
      console.log(res);
      if (res.status === 0) {
        layer.msg(res.message, { time: 500 }, function () {
          localStorage.setItem("token", res.token);
          location.href = "./index.html";
        });
      }
    },
  });
});
